<template>
	<view>
		<!-- <view> -->
			<my-address></my-address>
		<!-- </view> -->
		<view class="cart-title">
			<uni-icons type="shop" size="18"></uni-icons>
			<text>购物车</text>
		</view>
		<uni-swipe-action>
			<block v-for="(item,index) in cart" :key="index">
				<uni-swipe-action-item :right-options="options" @click="swipeActionClickHandler(item)">
					<my-goods :goods="item" :show-radio="true" :show-count="true"
						@radioStateChange="radioHandlerChange"></my-goods>
				</uni-swipe-action-item>
			</block>
		</uni-swipe-action>
		<!-- 底部 -->
		<my-settle></my-settle>
	</view>
</template>

<script>
	import badgeMixins from '../../mixins/tabbar-badge.js'
	import {
		mapState,
		mapMutations
	} from 'vuex'
	export default {
		mixins: [badgeMixins],
		data() {
			return {	
				options: [
					{
						text: '删除',
						style: {
							backgroundColor: '#c00000'
						}
					}
				]
			};
		},
		computed: {
			...mapState('my_cart', ['cart'])
		},
		onShow() {

		},
		methods: {
			...mapMutations('my_cart', ['updateGoodsState','removeGoods']),
			radioHandlerChange(goods) {
				this.updateGoodsState(goods)
			},
			swipeActionClickHandler(goods) {
				this.removeGoods(goods)
			}
		}
	}
</script>

<style lang="scss">
	.cart-title {
		display: flex;
		align-items: center;
		height: 40px;
		padding-left: 5px;
		font-size: 14px;
		border-bottom: 1px solid #efefef;

		text {
			margin-left: 10px;
		}
	}
</style>
